#include "stdafx.h"
#include "LitCoreComponent.h"

Lit::CoreComponent::CoreComponent(){}
Lit::CoreComponent::~CoreComponent(){}

#ifdef LIT_OGRE_SUPPORT
	void Lit::CoreComponent::initialise( const OgreDetails&  ){}
	bool Lit::CoreComponent::renderOneFrame( float dt ){ return true; }
#else
	void Lit::CoreComponent::initialise(){}
#endif

void Lit::CoreComponent::shutdown(){}

Lit::CoreComponentList::CoreComponentList(){}
Lit::CoreComponentList::CoreComponentList( CoreComponentPtr type ){ add( type ); }
Lit::CoreComponentList::CoreComponentList(const Lit::CoreComponentList::vec_t& types) : mTypes(types){}
Lit::CoreComponentList::CoreComponentList(const Lit::CoreComponentList& list) : mTypes(list.mTypes){}
Lit::CoreComponentList::~CoreComponentList(){}

bool Lit::CoreComponentList::has( Lit::CoreComponent::Type component ) const
{
	for( auto i=mTypes.begin(); i!=mTypes.end(); i++ )
		if( (*i)->type() == component ) return true;
	return false;
}

void Lit::CoreComponentList::add( CoreComponentPtr comp ){ 
	if( !has(comp->type()) ) mTypes.push_back( comp );
}
void Lit::CoreComponentList::remove( CoreComponent::Type comp ){ 
	if( !has(comp) ) return;
	for( auto i=mTypes.begin(); i!=mTypes.end(); i++ )
		if( (*i)->type() == comp )
		{
			mTypes.erase( i );
			return;
		}
}
bool Lit::CoreComponentList::operator[]( Lit::CoreComponent::Type component ) const
{
	for( auto i=mTypes.begin(); i!=mTypes.end(); i++ )
		if( (*i)->type() == component )
			return true;
	return false;
}
Lit::CoreComponentList& Lit::CoreComponentList::operator << ( CoreComponentPtr type )
{
	add( type );
	return *this;
}

Lit::CoreComponentList::vec_t&  Lit::CoreComponentList::types(){
	return mTypes;
}
const Lit::CoreComponentList::vec_t&  Lit::CoreComponentList::types() const{
	return mTypes;
}
void Lit::CoreComponentList::reset(){ mTypes.clear(); }